package karaokestrong.servlets;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import karaokestrong.excepcion.DAOExcepcion;
import karaokestrong.modelo.Comentario;
import karaokestrong.negocio.GestionComentario;

/**
 * Servlet implementation class ServletComentarSala
 */
@WebServlet("/ServletComentarSala")
public class ServletComentarSala extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ServletComentarSala() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		GestionComentario Comentarioservlet = new GestionComentario();
		
		try{
		Comentario comentario = new Comentario();
		
		
	//	comentario.setIdComentario(Integer.parseInt(request.getParameter("idcomentario")));
		comentario.setCalificacionComentario(request.getParameter("calificacion"));
		comentario.setdescripcionComentario(request.getParameter("descripcion"));
		comentario.setIdsala(Integer.parseInt(request.getParameter("txtSala")));
		
		
		
		
		Comentarioservlet.insertar(comentario);
		
		request.getRequestDispatcher("mensajeComentario.jsp").forward(request, response);
		
		} catch (DAOExcepcion e) {
			System.out.println("Fallo la insercion: " + e.getMessage());
		}
		
	}

}
